//
//  ControllerPopAnimator.m
//  MyFunctionDemo
//
//  Created by Ting Han on 2017/9/1.
//  Copyright © 2017年 Ting Han. All rights reserved.
//

#import "ControllerPopAnimator.h"
#import "UIView+SetRect.h"
#import "UIView+AnimationProperty.h"

@implementation ControllerPopAnimator
- (void)transitionAnimation {
    
    // http://stackoverflow.com/questions/25513300/using-custom-ios-7-transition-with-subclassed-uinavigationcontroller-occasionall
    
    [self.containerView insertSubview:self.toViewController.view belowSubview:self.fromViewController.view];
    
    //AnimationsListController *controller = (AnimationsListController *)self.toViewController;
    
    [UIView animateWithDuration:self.transitionDuration - 0.1 delay:0.f options:UIViewAnimationOptionCurveEaseInOut animations:^{
        
      //  controller.view.alpha          = 1.f;
        self.toViewController.view.alpha = 1.f;
        self.fromViewController.view.x = [UIScreen mainScreen].bounds.size.width;
        
    } completion:^(BOOL finished) {
        
        [self completeTransition];
    }];
}

@end
